package br.edu.ufcg.greengrid.event;

public class JobSubmissionEvent extends Event implements Comparable<JobSubmissionEvent> {

	private String id;
	
	private long submittime;

	private long runtime;

	public JobSubmissionEvent(String id, long submittime, long runtime) {
		super();
		this.id = id;
		this.submittime = submittime;
		this.runtime = runtime;
	}

	public String getId() {
	
		return id;
	}

	public long getSubmittime() {
		return submittime;
	}

	public long getRuntime() {
		return runtime;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (int) (runtime ^ (runtime >>> 32));
		result = prime * result + (int) (submittime ^ (submittime >>> 32));
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		JobSubmissionEvent other = (JobSubmissionEvent) obj;
		if (runtime != other.runtime)
			return false;
		if (submittime != other.submittime)
			return false;
		return true;
	}

	@Override
	public int compareTo(JobSubmissionEvent o) {
		if(this.submittime != o.submittime){
			return this.submittime - o.submittime > 0 ? 1 : -1;
		}
		
		if(this.runtime != o.runtime){
			return this.runtime - o.runtime > 0 ? 1 : -1;
		}
		
		return 0;
	}

	
}
